#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll k;
string s;
char c1,c2;
int main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin>>k>>s>>c1>>c2;
	ll sz=s.size();
	ll ret=0;
	ll sum=0;
	for (ll i=k-1,j=0;i<sz;i++,j++){
		if (s[j]==c1) sum++;
		if (s[i]==c2) ret+=sum;
	}
	cout<<ret;
	return 0;
} 
